package com.minedata.authorization.config;

import org.apache.shiro.authc.AuthenticationToken;

public class StatelessAuthenticationToken implements AuthenticationToken {
	
    private static final long serialVersionUID = 1L;
    private Integer id;//用户id；
    private String username;//用户名；
    private String digest;//凭证即客户端传入的消息摘要。
    public boolean byId;
   
    public StatelessAuthenticationToken() {
    }
    
    public StatelessAuthenticationToken(String username, String digest) {
       super();
       this.username = username;
       this.digest = digest;
       this.byId = false;
    }
    
    public StatelessAuthenticationToken(Integer id, String digest) {
        super();
        this.id = id;
        this.digest = digest;
        this.byId = true;
     }
   
	@Override
	public Object getPrincipal() {
		// TODO Auto-generated method stub
		if(byId)
			return id;
		else
			return username;
	}

	@Override
	public Object getCredentials() {
		// TODO Auto-generated method stub
		return digest;
	}
	
    public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUsername() {
        return username;
     }
  
     public void setUsername(String username) {
        this.username = username;
     }
 
  
     public String getDigest() {
        return digest;
     }
  
     public void setDigest(String digest) {
        this.digest = digest;
     }
}
